package cn.edu.ncut.cs.springboot.springbootdatabase.service.impl;
import cn.edu.ncut.cs.springboot.springbootdatabase.dao.PrisonGuardRepository;
import cn.edu.ncut.cs.springboot.springbootdatabase.entity.PrisonGuard;
import cn.edu.ncut.cs.springboot.springbootdatabase.service.PrisonGuardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;

@Service
public class PrisonGuardServiceImpl implements PrisonGuardService {
    @Autowired
    private PrisonGuardRepository prisonGuardRepository;
    @Override
    public List<PrisonGuard> findAll() {
        System.out.println(prisonGuardRepository.findAll());
        return prisonGuardRepository.findAll();
    }
    @Override
    public Optional<PrisonGuard> findById(Integer id) {
        return prisonGuardRepository.findById(Long.valueOf(id));
    }

    @Override
    public PrisonGuard savePrisonGuard(PrisonGuard prisonGuard) {
        return prisonGuardRepository.save(prisonGuard);
    }

    @Override
    public void deletePrisonGuard(Integer id) {
        prisonGuardRepository.deleteById(Long.valueOf(id));
    }
}
